package com.mybatis.config;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liuxiaoding
 * @Date 2019/11/18
 **/
@ControllerAdvice
public class CommonExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value =Exception.class)
    public Object exceptionHandler(Exception ex){
        JSONObject data = new JSONObject();
        data.put("code", 500);
        data.put("msg", ex.getMessage());
        data.put("info","统一异常处理");
        return data;
    }
}
